package com.kingyea.mobilepolice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 注意,启动类  要放在所有需要注入的包的外面或者同级
 * Created by Mr.Lin on
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)// 开启权限注释
@ComponentScan(basePackages = {"com", "org.springframework.security.oauth2.provider.token.store.redis", "com.kingyea.mobilepolice.config.activemq"})
@EnableFeignClients
//@FeignClient
@EnableAspectJAutoProxy(exposeProxy = true)//开启cglib
//@EnableJpaAuditing(auditorAwareRef = "auditorAware")// 开启 Spring Data 自动审计功能 （自动完成以下属性 @CreatedBy，@LastModifiedBy，@CreatedDate，@LastModifiedDate注解 ）
//@EnableJpaRepositories(repositoryBaseClass = WiselyRepositoryImpl.class)
public class AuthServerApplication extends WebMvcConfigurerAdapter {

//	@Bean(name = "auditorAware")
//	public AuditorAware<String> auditorAware() {
//		return ()-> SecurityUtils.getCurrentUserUsername();
//	}

    public static void main(String[] args) {
        SpringApplication.run(AuthServerApplication.class, args);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        System.out.println(" add view --------------------------------------------- ");
//		registry.addViewController("/login").setViewName("login");
//		registry.addViewController("/oauth/confirm_access").setViewName("authorize");
    }


}
